package dk.mitaffald.main;

import dk.tankegang.mitaffald.R;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings.ZoomDensity;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.Toast;
  
@SuppressLint("SetJavaScriptEnabled")
public class TankegangWeb extends Activity
{
    final Activity activity = this;
	String url = "http://TANKEGANG.DK";
  
	@Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.webview);
 
        Button btn_back = (Button) findViewById(R.id.webview_tilbage);
        
        WebView webView = (WebView) findViewById(R.id.webView1);
        webView.getSettings().setBuiltInZoomControls(true);

        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setSupportMultipleWindows(true);
        webView.getSettings().setDefaultZoom(ZoomDensity.MEDIUM);
        webView.setPadding(0, 0, 0, 0);
        webView.getSettings().setLoadWithOverviewMode(true);
        webView.getSettings().setUseWideViewPort(true);
        webView.getSettings().setLoadsImagesAutomatically(true);
        webView.getSettings().setAllowFileAccess(true);
        
               webView.setWebChromeClient(new WebChromeClient() {
            public void onProgressChanged(WebView view, int progress)
            {
                activity.setTitle("Henter...");
                activity.setProgress(progress * 100);
  
                if(progress == 100)
                    activity.setTitle("Tankegang.dk");
            }
        });
  
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
            {
	            Toast.makeText(TankegangWeb.this, "Error has occurred, Check your connection", Toast.LENGTH_SHORT).show();
	        }
  
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url)
            {
            	view.loadUrl(url);
                return true;
            }
        });

        webView.loadUrl(url);


    btn_back.setOnClickListener(new View.OnClickListener() {
		
		@Override
		public void onClick(View view) {
			finish();
			}
    	});

    }
}